class Solution(object):
    def reachNumber(self, target):
        """
        :type target: int
        :rtype: int
        """
        if target == 0:
            return 0
        else:
            target = abs(target)
            if target == 2:
                return 3
            n = (2 * target + 0.25) ** 0.5 - 0.5
            if n == int(n):
                return int(n)
            else:
                base = int(n) + 1
                if (base * (base + 1) // 2 - target) % 2 == 0:
                    return base
                else:
                    if (base + 1) % 2 == 0:
                        return base + 2
                    else:
                        return base + 1

data = Solution()
target = 3
print(data.reachNumber(target))